add docs
authorMatthias Clasen <matthiasc@src.gnome.org>
Thu, 1 Jun 2006 05:19:16 +0000 (05:19 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 1 Jun 2006 05:19:16 +0000 (05:19 +0000)
ChangeLog
ChangeLog.pre-2-10
gtk/gtkprintoperation.c

index a1578e3764018f814d7ba61b18223ce3fd203415..1b1ce4334fb3cba22b5c952e4217e5381610c261 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2006-06-01  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkprintoperation.c: Add some examples to the docs.
+
        * gtk/gtkprintbackend.c (gtk_print_backend_class_init): 
        Intern signal names.
 
index a1578e3764018f814d7ba61b18223ce3fd203415..1b1ce4334fb3cba22b5c952e4217e5381610c261 100644 (file)
@@ -1,5 +1,7 @@
 2006-06-01  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkprintoperation.c: Add some examples to the docs.
+
        * gtk/gtkprintbackend.c (gtk_print_backend_class_init): 
        Intern signal names.
 
index b568c94d4a278a7403848f0c82f8a954b5edafa1..64781ebcca8afe6d21cb000488b19849be5e03d9 100644 (file)
@@ -379,7 +379,44 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
    * from @context using gtk_print_context_get_cairo_context().
    *
    * <informalexample><programlisting>
-   *  FIXME: need an example here
+   * static void
+   * draw_page (GtkPrintOperation *operation,
+   *            GtkPrintContext   *context,
+   *            gint               page_nr,
+   *            gpointer           user_data)
+   * {
+   *   cairo_t *cr;
+   *   PangoLayout *layout;
+   *   gdouble width, text_height;
+   *   gint layout_height;
+   *   PangoFontDescription *desc;
+   *   
+   *   cr = gtk_print_context_get_cairo_context (context);
+   *   width = gtk_print_context_get_width (context);
+   *   
+   *   cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT);
+   *   
+   *   cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
+   *   cairo_fill (cr);
+   *   
+   *   layout = gtk_print_context_create_pango_layout (context);
+   *   
+   *   desc = pango_font_description_from_string ("sans 14");
+   *   pango_layout_set_font_description (layout, desc);
+   *   pango_font_description_free (desc);
+   *   
+   *   pango_layout_set_text (layout, "some text", -1);
+   *   pango_layout_set_width (layout, width);
+   *   pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
+   *                         
+   *   pango_layout_get_size (layout, NULL, &amp;layout_height);
+   *   text_height = (gdouble)layout_height / PANGO_SCALE;
+   *   
+   *   cairo_move_to (cr, width / 2,  (HEADER_HEIGHT - text_height) / 2);
+   *   pango_cairo_show_layout (cr, layout);
+   *
+   *   g_object_unref (layout);
+   * }
    * </programlisting></informalexample>
    *
    * Use gtk_print_operation_set_use_full_page() and 
@@ -1856,7 +1893,38 @@ print_pages (GtkPrintOperation *op,
  * See gtk_print_operation_run_async() if this is a problem.
  *
  * <informalexample><programlisting>
- *  FIXME: need an example here
+ * if (settings != NULL)
+ *   gtk_print_operation_set_print_settings (print, settings);
+ *   
+ * if (page_setup != NULL)
+ *   gtk_print_operation_set_default_page_setup (print, page_setup);
+ *  
+ * g_signal_connect (print, "begin-print", 
+ *                   G_CALLBACK (begin_print), &amp;data);
+ * g_signal_connect (print, "draw-page", 
+ *                   G_CALLBACK (draw_page), &amp;data);
+ * 
+ * res = gtk_print_operation_run (print, parent, &amp;error);
+ * 
+ * if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
+ *  {
+ *    error_dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ *                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+ *                                          GTK_MESSAGE_ERROR,
+ *                                          GTK_BUTTONS_CLOSE,
+ *                                          "Error printing file:\n%s",
+ *                                          error->message);
+ *    g_signal_connect (error_dialog, "response", 
+ *                      G_CALLBACK (gtk_widget_destroy), NULL);
+ *    gtk_widget_show (error_dialog);
+ *    g_error_free (error);
+ *  }
+ * else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
+ *  {
+ *    if (settings != NULL)
+ *     g_object_unref (settings);
+ *    settings = g_object_ref (gtk_print_operation_get_print_settings (print));
+ *  }
  * </programlisting></informalexample>
  *
  * Return value: the result of the print operation. A return value of